<?php
/**
 * Created by PhpStorm.
 * User: zhang-hong
 * Date: 2017/4/11
 * Time: 13:34
 */
class BingfanghistorydatauploadController extends Yaf_Controller_Abstract
{

    function IndexAction()
    {
        $request = $this->getRequest();
        $zhixing_id = $request->getPost("id","");
        $bingqu = $request->getPost("bingqu","");
        $bingfanghao = $request->getPost("bingfanghao","");
        $state = $request->getPost("state","");
        $user_number = $request->getPost("user_number","");
        $user_department_id =  $request->getPost("user_department_id","");
        $yiyuan_id =  $request->getPost("yiyuan_id","");
        $bingfang_mode = new BingFangChaXunModel();
        if($zhixing_id == "")
        {
            Utility::apiJsonError(20080, 'id为空');
        }

        if($bingfanghao == "")
        {
            Utility::apiJsonError(20081, '病房号为空');
        }

        if($state == "")
        {
            Utility::apiJsonError(20082, '状态为空');
        }

        if($user_number == "")
        {
            Utility::apiJsonError(20083, '用户号为空');
        }

        if($user_department_id == "")
        {
            Utility::apiJsonError(20084, '科室号为空');
        }
        if($bingqu == "")
        {
            Utility::apiJsonError(20085, '病区为空');
        }

        //$zhixing_id = '11';
        //$bingqu = '22';
        //$state = '33';
        //$modify_time = '2017-03-22';
        if(Yaconf::get("config$yiyuan_id.fenbiao_state") == 'true')     //如果分表机制开启
        {
            $data_bingfang_xuncha_histroy = "data_bingfang_xuncha_histroy".$user_department_id;
        }
        else
        {
            $data_bingfang_xuncha_histroy = "data_bingfang_xuncha_histroy";
        }


        $inser_data = array();
        $inser_data = array(
            //'id' => $one['id'],
            'zhixing_id' => $zhixing_id,
            'bingqu' => $bingqu,
            'bingfanghao' => $bingfanghao,
            'state' => $state,
            'beizhu' => "",
            'qrcode' => "",
            'user_number' => $user_number,
            'modify_time' => date('Y-m-d H:i:s',time()),
            'yiyuan_id' => $yiyuan_id
        );

        //增加上传状态失败处理
        $sql_act = $bingfang_mode->addBingFangXunChaHis($data_bingfang_xuncha_histroy,$inser_data);
        //添加数据到表


        //1:ok
        $staus = array(
            'state' => $sql_act ? '1' : '0',
            'error' => 200,
            'msg' => "",
        );
        Utility::apiJsonResultExtends($staus);
    }
}